<?php if ( $activity_lottery->num_rows() > 0 ): ?>
    <?php foreach ($activity_lottery->result() as $key => $val ): ?>
        <?php if ( $val->sort != 0 ): ?>
        <li>
            <a href="<?php echo site_url('home/lottery/index.html').'?id=', $val->lottery_id; ?>">
                <div class="drawname flex">
                    <div class="drawLeft <?php echo 'type' . ( (($val->sort) % 5) ? (($val->sort) % 5) : '5' );?>">
                        <span>编号</span>
                        <p><?php echo $val->lottery_id;?></p>
                    </div>
                    <div class="drawRight flex-1">
                        <p><?php echo $val->lottery_name;?></p>
                        <span>已中奖人数：<em><?php echo $val->winners_total;?></em></span>
                        <i>已抽奖人数：<?php echo $val->user_total;?></i>
                    </div>
                </div>
                <div class="godraw am-cf">
                    <?php $start_date = time();?>
                    <?php $end_date = strtotime($val->end_date);?>
                    <?php $time = (int)$end_date - (int)$start_date;?>
                    <?php if ( $time > 0 ): ?>
                        <?php $day = floor($time/60/60/24); if ($day <= 9) $day = '0' . $day;?>
                        <?php $hour = floor($time/60/60%24); if ($hour <= 9) $hour = '0' . $hour;?>
                        <?php $minute = floor($time/60%60); if ($minute <= 9) $minute = '0' . $minute;?>
                        <?php $second = floor($time%60); if ($second <= 9) $second = '0' . $second;?>
                        <div class="time">
                            <span data-count="<?php echo $activity_lottery->num_rows();?>" >距结束</span>
                            <div data-id ="<?php echo 'id' . $val->lottery_id;?>" data-end-time ="<?php echo date('Y/m/d H:i:s',strtotime($val->end_date));?>" class="countdown am-fl <?php echo 'downList'.($key+1);?>" id="<?php echo 'id' . $val->lottery_id;?>">
                                <i class="day"><?php echo $day?></i><em>天</em>
                                <i class="hour"><?php echo $hour;?></i><em>时</em>
                                <i class="minute"><?php echo $minute;?></i><em>分</em>
                                <i class="second"><?php echo $second;?></i><em>秒</em>
                            </div>
                        </div>
                        <div class="chouj">去抽奖<i class="iconfont">&#xe673;</i></div>
                    <?php else:?>
                        你来晚了，抽奖活动已结束！
                    <?php endif ?>
                </div>
            </a>
        </li>
        <?php endif ?>
    <?php endforeach ?>
<?php endif ?>